<html>
<head>
    <title>个人备忘系统</title>
    <style>
        * {margin: 0; padding: 0; font-size: 14px;}
        a{text-decoration: none}
        .box {width: 1000px; margin: 0 auto}
        .header{height:100px; background-color:#555;
            display: flex; justify-content: space-between; color: #fff}
        .logo {
            padding: 20px 20px;
            font-size: 30px; font-weight: bold;
        }
        .top-op {
            padding: 10px 20px;
        }
        .top-op a{
            color: #ffffff;
        }
        .top-op a:hover{
            text-decoration: underline;
        }
        .lists{
            margin-top: 10px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
        }
        table tr th {
            background-color: #ccc;
        }
        table tr td, table tr th{
            border: 1px solid #ddd;
            padding: 3px;
        }
    </style>
</head>
<body>
<div class="box">
    <?php include_once './Views/common/header.php';?>
    <div class="lists">
        <div>
            <a href="/index.php?c=center&a=add">新增备忘信息</a>
        </div>
        <table width="100%">
            <thead>
                <tr>
                    <th width="10%">序号</th>
                    <th>内容</th>
                    <th width="10%">日期</th>
                    <th width="20%">操作</th>
                </tr>
            </thead>
            <tbody>
            <?php foreach ($items as $val):?>
                <tr>
                    <td align="center"><?php echo $val['id'];?></td>
                    <td><?php echo $val['content'];?></td>
                    <td align="center"><?php echo $val['complete_date'];?></td>
                    <td align="center">
                        <a href="/index.php?c=center&a=edit&id=<?php echo $val['id'];?>">编辑</a> |
                        <a href="javascript:deleteTask(<?php echo $val['id'];?>)">删除</a>
                    </td>
                </tr>
            <?php endforeach;?>
            </tbody>
        </table>
    </div>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script>
    function deleteTask(task_id) {
        if (confirm('是否确定删除此信息')) {
            var params = {
                task_id: task_id
            }
            jQuery.post('/index.php?c=center&a=deleteTask', params, function (data){
                if (data.code == 1) {
                    window.location.reload()
                }
            }, 'json')
        }
    }
</script>
</html>